#! /usr/bin/env python
# -*- coding: utf-8 -*-

danger_type = '罐区'  # 0
danger_type_key = 0
danger_level = '二级'  # 2
danger_level_key = 2
danger_name = 'test'
check_result = '通过'
check_result_key = 1
feedback_status = '已反馈'
feedback_status_key = 1
company_name = '福建优力特材料有限公司'
company_id = '1820379858379681793'

query_sql = '''
select count(*) from (
SELECT
	* 
FROM
	hgyq_major_hazard_sources.mw_m_major_hazard_source_check_result cr 
WHERE cr.is_deleted = 0
AND cr.option_type = ''' + str(check_result_key) + '''
AND cr.feedback_user IS NOT NULL
AND cr.major_hazard_id  IN ( SELECT id FROM hgyq_synthetical.ha_m_great_risk_bill 
	WHERE type = ''' + str(danger_type_key) + ''' AND LEVEL = ''' + str(
    danger_level_key) + ''' AND NAME LIKE "%''' + danger_name + '''%" AND create_dept = ''' + company_id + '''
	 )
) t
'''

reset_sql = '''
SELECT
	count(*)
FROM
	hgyq_major_hazard_sources.mw_m_major_hazard_source_check_result cr
WHERE
	cr.is_deleted = 0 
	AND cr.major_hazard_id  IN ( SELECT id FROM hgyq_synthetical.ha_m_great_risk_bill 
	WHERE create_dept = ''' + company_id + '''
	 )
'''

print(reset_sql)
